package bist.believeinstep.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import bist.believeinstep.domain.Video;
import bist.believeinstep.util.Constant.MediaType;
import bist.believeinstep.util.Constant.State;

public class VideoMapper implements RowMapper<Video>{
	public Video mapRow(ResultSet rs, int rowNum) throws SQLException{
		
		Video video = new Video();
		
		video.setId(rs.getInt("id"));
		video.setCode(rs.getString("code"));
		video.setName(rs.getString("name"));
		video.setIntroduction(rs.getString("introduction"));
		video.setDescriptions(rs.getString("description"));
		
		String state = rs.getString("state");
		video.setState(State.create(state));
		
		String type = rs.getString("type");
		video.setType(MediaType.create(type));
		
		video.setLink(rs.getString("link"));
		video.setCreated(rs.getTimestamp("created_date"));
		video.setModified(rs.getTimestamp("modified_date"));
		video.setCreatedBy(rs.getString("created_by"));
		video.setModifiedBy(rs.getString("modified_by"));
		
		return video;
	}
}
